package leetcode.part1;

import org.junit.Test;

public class S58 {
    public int lengthOfLastWord(String s) {
        int count=0;
        boolean flag=true;
        for (int i = s.length()-1; i >= 0; i--) {
            if (s.charAt(i)!=' '){
                count++;
                flag=false;
            }else {
                if (!flag) break;
            }
        }
        return count;
    }
    @Test
    public void test(){
        String s = "luffy is still joyboy";
        System.out.println(lengthOfLastWord(s));
    }
}
